package com.briup.smartcity_group7.web.controller;

import com.briup.smartcity_group7.bean.basic.Comment;
import com.briup.smartcity_group7.service.ICommentService;
import com.briup.smartcity_group7.util.Result;
import com.briup.smartcity_group7.util.ResultUtil;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Api(tags = "评论管理模块")
@RequestMapping("/auth/comment")
public class CommentController {
    @Autowired
    private ICommentService service;

    @PutMapping("/check")
    public Result updateStatus(Integer id,Integer status){
        service.checkComment(id,status);
        return ResultUtil.success();
    }

    @GetMapping("page")
    public Result findByPage(Integer pageNum,Integer pageSize,String keywords){
        PageInfo<Comment> pageInfo = service.pageQuery(pageNum, pageSize, keywords);
        return ResultUtil.success(pageInfo);
    }

    @DeleteMapping
    public Result deleteById(Integer id){
        service.deleteById(id);
        return ResultUtil.success("删除成功");
    }

    @DeleteMapping("/batch")
    public Result batchDelete(int[] ids){
        service.batchDelete(ids);
        return ResultUtil.success("删除成功");
    }
}
